﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using Part3_IndividuleAssignment2.Models;

namespace Part3_IndividuleAssignment2.ViewModels
{
    public class NewAccount
    {
        const string EMAIL_REGEX =
          @"^(([^<>()[\]\\.,;:\s@\""]+"
        + @"(\.[^<>()[\]\\.,;:\s@\""]+)*)|(\"".+\""))@"
        + @"((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}"
        + @"\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+"
        + @"[a-zA-Z]{2,}))$";

        [Required(ErrorMessage = "First name is required")]
        [MaxLength(20, ErrorMessage = "First name must be between 2 to 20 characters.")]
        [MinLength(2, ErrorMessage = "First name must be between 2 to 20 characters.")]
        public string FirstName { get; set; }

        [Required(ErrorMessage = "Last name is required")]
        [MaxLength(20, ErrorMessage = "Last name must be between 2 to 20 characters.")]
        [MinLength(2, ErrorMessage = "Last name must be between 2 to 20 characters.")]
        public string LastName { get; set; }

        [Required(ErrorMessage = "Email address is required")]
        [RegularExpression(EMAIL_REGEX, ErrorMessage = "Not a valid email address")]
        public string Email { get; set; }

        [Required]
        public virtual string City { get; set; }
    }
}